//从服务器主动发送请求调用接口 根据id去查询
//从服务器主动发送请求
//http.request(options[, callback])

const http = require('http')

options = {
    hostname: 'localhost',
    port: 3000,
    protocol: "http:",
    path: '/books/book/18', // 18是 restful风格的get请求参数
}

let req = http.request(options, (res)=>{
    let info = ''
    res.on('data', (chunk)=>{
        info += chunk
    })
    res.on('end', ()=>{
        console.log(info)
    })
})

req.end()